void setAddress27_24P(uint32_t addr,uint32_t chipId) {
  PORTA = lowByte(addr) & 0xff;
//  portWrite(0, lowByte(addr) & 0xff);
  digitalWrite(Add_8, (addr >> 8) & 1);
  digitalWrite(Add_9, (addr >> 9) & 1);
  digitalWrite(Add_10, (addr >> 10) & 1);
  digitalWrite(Add_11, (addr >> 11) & 1);
}

void setAddress27_28P(uint32_t addr,uint32_t chipId) {
  PORTA = lowByte(addr) & 0xff;
//  portWrite(0, lowByte(addr) & 0xff);
  digitalWrite(Add_8, (addr >> 8) & 1);
  digitalWrite(Add_9, (addr >> 9) & 1);
  digitalWrite(Add_10, (addr >> 10) & 1);
  digitalWrite(Add_11, (addr >> 11) & 1);
  digitalWrite(Add_12, (addr >> 12) & 1);
  digitalWrite(Add_13, (addr >> 13) & 1);
  digitalWrite(A27_14, (addr >> 14) & 1);
  digitalWrite(A27_15, (addr >> 15) & 1);
}

void setAddress27_32P(uint32_t addr,uint32_t chipId) {
  PORTA = lowByte(addr) & 0xff;
//  portWrite(0, lowByte(addr) & 0xff);
  digitalWrite(Add_8, (addr >> 8) & 1);
  digitalWrite(Add_9, (addr >> 9) & 1);
  digitalWrite(Add_10, (addr >> 10) & 1);
  digitalWrite(Add_11, (addr >> 11) & 1);
  digitalWrite(Add_12, (addr >> 12) & 1);
  digitalWrite(Add_13, (addr >> 13) & 1);
  digitalWrite(A27_32P_14, (addr >> 14) & 1);
  digitalWrite(A27_32P_15, (addr >> 15) & 1);
  digitalWrite(A27_32P_16, (addr >> 16) & 1);
  digitalWrite(A27_32P_17, (addr >> 17) & 1);
  digitalWrite(A27_32P_18, (addr >> 18) & 1);
  digitalWrite(A27_32P_19, (addr >> 19) & 1);
}

void setAddress28_24P(uint32_t addr) {
  PORTA = lowByte(addr) & 0xff;
//  portWrite(0, lowByte(addr) & 0xff);
  digitalWrite(Add_8, (addr >> 8) & 1);
  digitalWrite(Add_9, (addr >> 9) & 1);
  digitalWrite(Add_10, (addr >> 10) & 1);
}

void setAddress28_28P(uint32_t addr) {
  PORTA = lowByte(addr) & 0xff;
//  portWrite(0, lowByte(addr) & 0xff);
  digitalWrite(Add_8, (addr >> 8) & 1);
  digitalWrite(Add_9, (addr >> 9) & 1);
  digitalWrite(Add_10, (addr >> 10) & 1);
  digitalWrite(Add_11, (addr >> 11) & 1);
  digitalWrite(Add_12, (addr >> 12) & 1);
  digitalWrite(Add_13, (addr >> 13) & 1);
  digitalWrite(A28_14, (addr >> 14) & 1);
}

void setAddress29(uint32_t addr) {
  setAddress29(addr,29040);
}

void setAddress29(uint32_t addr,uint32_t chipId) {
  digitalWrite(A29_16, (addr >> 16) & 1);
  digitalWrite(A29_17, (addr >> 17) & 1);
  digitalWrite(A29_18, (addr >> 18) & 1);

  PORTA = lowByte(addr) & 0xff;
  PORTC = addr>>8 & 0xff;
//  portWrite(0, addr & 0xff);
//  portWrite(2, addr>>8 & 0xff);

}
